<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="st" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="j" uri="j/tags"%>
<%@ taglib prefix="easyui" uri="http://www.joyi.cn/easyui/tags" %>
<%@ taglib prefix="joyi" uri="http://www.joyi.cn/tags" %>

<st:page title="用户管理">
    <div data-options="region:'west',title:'用户分类管理',split:true" style="width:260px;">
        <table id="dgUserCategory" class="easyui-treegrid"
               data-options="toolbar:'#ucToolbar',fit:true,url:'<joyi:req rid="20151012000000000002"/>',idField:'id',treeField:'name'">
            <thead>
            <tr>
                <th data-options="field:'id',width:70,formatter:optFormatter">操作</th>
                <th data-options="field:'name',width:180">用户分类</th>
            </tr>
            </thead>
        </table>
        <%--<joyi:dataGrid id="dg" key="userCategoryList" toolbarId="ucToolbar"/>--%>
        <div id="ucToolbar">
            <easyui:linkButton name="增加用户分类" iconKey="project" onClick="editUc('')"/>
        </div>
    </div>
    <div data-options="region:'center',title:'用户管理'" style="padding:5px;background:#f00;">

    </div>
    <script>
        function optFormatter(value,row,index){
            var opt = '';
            opt = "<a href='javascript:void(0);' onclick='editUc(\""+row["id"]+"\")'";
            opt += ">修改</a>";

            opt += " <a href='javascript:void(0);' onclick='delUc(\""+value+"\")'";
            opt += ">删除</a>";
            return opt;
        }
        /**
        * 显示增加用户分类页面
         */
        function addUc(){
            /*j.open("/user/pd?act=jsp&jsp=<j:des data="train/editUserCategory"/>",
             "editUcWin",{},300,280);*/

            editUc('');
        }
        function reloadUserCategoryData(){
            $("#dgUserCategory").treegrid("reload");
        }
        /*
        删除用户分类
         */
        function delUc(ucId){
            if(window.confirm("确认要删除？")) {
                Http.post("<joyi:req rid="20151014000000000003"/>",{id:ucId},function(data){
                    alert(data.data["c_name"]);
                    reloadUserCategoryData();
                });
            }
        }
        /**
          * 显示修改用户分类界面
         */
        function editUc(ucId){
            j.open("<joyi:req rid="20151014000000000005"/>&id="+ucId,
                "editUcWin",{},300,280);
        }
    </script>
</st:page>